﻿using FluentNHibernate.Mapping;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YYSite.Domain.System;
using YYSite.Domain.System.IdentityUsers;
using YYSite.Domain.System.Roles;

namespace YYSite.Repository.System.Roles
{
   public class RoleMap:ClassMap<Role>
    {
        public RoleMap()
        {
            this.Table("Role");
            this.Schema(SystemConstant.Schema);

            this.Id(c => c.Id);
            this.Map(c => c.Name).Not.Nullable().Length(128).Unique();
            this.Map(c => c.Description).Length(256);
            this.Map(p => p.CreateTime).Default("GETDATE()").Not.Nullable();

            this.HasManyToMany<IdentityUser>(p => p.IdentityUsers) .AsSet().LazyLoad().ParentKeyColumn("RoleId") .ChildKeyColumn("UserId").Table("System.UserRole");
        }
    }
}
